package drg_group.wuhan_2022.MDC;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;

import drg_group.wuhan_2022.Base;
import drg_group.wuhan_2022.MedicalRecord;
import drg_group.wuhan_2022.ADRG.*;

public class MDCS{
    public static String group(MedicalRecord record){
        String[] mdc_zd={"A75.000x004","A92.900","A99.x00","T98.200x012","A49.812","A28.900","R50.900","B01.900x001","A68.100","B48.800x001","A23.000","A49.803","A40.300","B02.700","A96.100x001","A49.103","T85.709","B67.601","A24.300","A40.100","A68.000","B00.700","A97.900","B00.901","B34.102","A30.400x002","B08.400x003","A27.900x002","A50.700","B66.800x001","A23.200","A21.700","B04.x00","A79.800x002","A31.800x003","B68.900x003","A24.201","T82.700x004","B53.000x001","B60.000x001","A67.000","A65.x00","A30.900","A41.400x001","A41.500x083","A52.800","A41.500x087","A49.814","T86.807","A40.903+N16.0*","B54.x00x006","B68.900x004","B99.x00x001","B42.100x003","A38.x00x011","T81.401","T82.700x002","T85.712","T85.700x809","B40.700","A75.200x001","A23.300","B66.800x004","T85.700x104","A18.800x001","A49.004","A58.x01","A20.700","A43.800x001","A98.000","A66.000","B50.800","A01.000x020","A22.100x003","A98.400","A49.805","B34.101","A75.000x003","A98.400x001","A95.900","A01.000","A28.000","A98.300","A30.300","P37.000","B34.200","A35.x00x001","A02.900x004","A27.800x001","B65.101","A28.801","A23.100","A49.003","R50.800x002","A31.901","A30.000x001","A25.000x001","A49.300","R68.801","B83.000x001","A31.900x001","A97.200","A77.100","B06.800","T82.701","B36.800","B44.100x003","A67.200","B03.x00","T81.400x005","A49.800x015","A41.400","B02.800","A41.000","A49.806","B44.700","A24.202","B01.900x002","A69.900","B51.800","A20.000x001","A40.901+N08.0*","A49.813","B74.100x003","A52.700x001","A26.800x001","A01.003","B66.100","A30.300x001","A77.000","B27.900x001","A54.900x001","B65.200x001","B81.000","A41.801","A31.800x005","B42.900","A01.100","A56.800","B55.100","B33.100","A41.505","T81.400x002","A40.800","A96.000","A22.900","B08.801","A77.800","A95.100","B66.000","A48.800x002","A40.900","B46.800x002","A67.100","B48.300","B83.400","B71.800","B71.900","A92.001","B54.x00x004","A59.900","B48.401","A79.900","A77.900","A94.x01","A51.200","A19.900","T80.200x004","B83.800x009","B66.900","R50.901","B08.401","B48.201","A41.902+N08.0*","B52.900x001","A32.900","A77.200","B05.900x005","B53.800x001","A30.900x002","B67.901","A38.x00x013","B41.900","B08.000x002","A49.900","A23.100x001","A92.000","A19.200x001","A48.800","B33.800","B74.200x001","T82.700x001","A02.100x002","A55.x00","B05.900x001","B70.100","A49.804","B83.000","B65.900x006","A92.300x001","B66.800x005","A19.902","A25.900","T85.700x808","B75.x00","A53.000x002","T82.700x010","A75.100","A20.803","T81.400x004","B56.900x001","B83.800x006","A21.000","B83.200x001","A06.900","A49.101","B83.100","B27.001","A95.000","A92.800","B49.x00x007","A49.817","B34.400","B68.000","A41.802","A49.301","B85.400","T85.702","B42.100x001","B42.100","A49.802","B76.800","A24.101","B74.400x001","B89.x00","B39.300","B43.801","B83.800x002","B66.101","Z03.000","A41.800x002","B46.900x002","A79.901","A26.700x001","A02.901","P37.100","A93.802","B46.400","A30.900x004","A41.803","B83.800x004","A30.900x003","A21.700x002","A22.700","A01.000x004","A31.800x007","P37.300","T81.406","B34.801","A30.800","A98.200","B88.800x002","A77.300x001","T82.700x011","B27.800","A49.800x020","B38.700","A20.802","A41.805","B34.000","A31.800x001","A41.807","B40.800","B08.800x006","B65.800x001","A49.200","A01.000x006","A23.800","A41.804","B38.800","B74.000x001","B65.100x001","A49.902","A23.000x001","B42.800","T85.708","A01.000x018","A70.x00","B74.900","A19.901","A52.801","B08.000x001","A23.900x001","B48.700","B56.000x001","A49.000","A19.900x005","A24.400","A48.400","A30.500","A54.900","A30.100x001","B34.100","A50.200","B68.100","T81.402","B67.401","T85.703","A79.801","R50.802","A27.000","B37.700","T85.711","B25.900x002","A01.400","B33.802","A02.800","A49.800x019","A68.900","R50.900x002","T81.400x006","A38.x00x012","A77.000x001","B81.200","B40.900","B73.x00","A77.200x001","A31.800x004","A32.700","T85.706","B46.500","A50.600","B74.800x001","B74.400x003","A49.811","B45.700","B68.901","A49.100x006","B74.900x005","B55.900","A02.900x002","A64.x00","A53.900","B58.900x001","B76.900","R50.801","A41.806","A31.800x006","A36.900x002","B25.900x001","A31.801","A04.701","A78.x00","A38.x00","B03.x00x003","A42.700","A41.900","A28.001","A31.803","A49.800x014","A31.000x005","B50.801","A69.800","A27.800","B60.000","B79.x00","A54.900x002","B08.000x004","B34.400x002","B34.800x002","A24.000x002","B83.300","A23.900x004","B34.900","B38.900","B74.300","B05.901","A75.001","T79.300x001","A49.201","B67.301","A02.100","A41.101","A41.501","A44.800","A97.000","T81.403","B44.900x001","B00.701","B83.000x002","A31.800x002","A49.002","B48.402","A92.100","T82.700x005","B02.900x002","B05.800x008","B37.900","A26.900","T82.700x009","B34.800x003","A01.200","A41.200","B34.800x004","B05.800x010","A25.100x001","B64.x00","A38.x00x014","B66.800x006","J10.800x002","B80.x00","A41.506","B74.000x003","A50.100","A19.200","B88.800x001","B51.000x001+D77*","A19.100","A92.300","B66.800x003","A24.102","A96.800","B37.901","A77.100x001","A30.300x002","O98.600x001","A30.200x001","T85.700x103","T82.700x003","B48.400","B57.500","B03.x00x002","B27.100","A79.100","A24.002","A21.900x001","B51.000","B34.300","B50.900x001","A19.800","B66.200","A40.000","A01.300","A41.100x002","A43.900","B54.x00","A50.000","T88.000","A31.802","B57.100","A66.800","A41.904+N16.0*","A75.900","B36.801","B41.800x001","A49.808","A19.900x004","T81.405","T85.701","A24.100x002","B83.201","B76.100","T80.201","B55.000","A77.900x001","A24.000","A30.400","B00.900x007","A98.500x001+N08.0*","A92.400","B00.900x005","A69.200","B33.400x001+J17.1*","A21.800","A49.100x004","A49.810","A44.900","B33.801","B67.400x001","B78.901","A49.801","B46.800x001","B02.900x003","A06.300x001","B46.100x001+G99.8*","A49.800x023","B55.000x003","B65.900x008","B70.000","A38.x00x010","A49.809","A74.900","A54.808","A79.000","A01.000x019","A66.700","A49.901","T85.710","B39.400x001","B74.200x003","B51.900","A66.100","B66.000x001","B65.800x002","A96.900","A92.200","B71.100","B39.900","A49.100x005","A49.807","A93.100","B68.900x002","B74.400","A93.000","B83.800x001","A77.300","A01.000x007","B34.300x002","A52.900","A67.300","B65.800x003","B48.300x001","T82.700x007","B34.400x001","B05.900x002","A63.800","B00.902","A02.101","A28.200","A66.200","B03.x00x004","A30.400x001","T98.200x021","A30.500x001","A20.801","B83.900","A50.900","A49.815","B42.700","A44.000","A96.200","A93.200","B71.000","A49.800x003","B48.200","B74.902","A40.200","A42.900","B39.500x001","A26.700","A01.000x017","B45.900","B74.901","B33.300x001","A41.900x004","B39.400","A41.300","B52.800","A24.001","A98.800","B41.700","B53.100","A20.000","A75.000x002","A66.400","T82.700x008","B41.800x003","T81.400x001","T80.200","A66.900","A36.900","B39.500","A49.102","A41.503","R50.803","B06.900x001","T81.404","B83.800x007","A20.900x002","B47.100","A51.500","A75.300x001","B55.000x001","A51.400x001","A21.800x001","B99.x01","B65.900x007","B54.x00x008","A53.000x001","A49.001","T84.701","A96.100","B56.100x001","B43.800","A98.100","B37.700x001","B37.808","B78.700","B74.400x002","B27.000","A41.504","B25.800x001","B02.800x001","B66.800x002","B48.000x001","A26.900x002","A30.200","A32.701","A41.502","B42.100x002","A51.900","B67.700x001","B69.900x001","A97.100","B43.900","A67.900"};
        String[] dept_list={};
        if (!(true && Base.contains(mdc_zd,record.zdList[0]))){
            return "";
        }
        
        Base.groupMessages.putMessage(record.Index,"符合MDCS入组条件，匹配规则：主诊断匹配");
        String result;

        result=SB1.group(record);
        if (result.length()>0){
            return result;
        }

        if (false && record.ssList!=null && record.ssList.length>0  && Base.intersect(Base.SS_VALID,record.ssList)){
            Base.groupMessages.putMessage(record.Index,"符合SQY入组条件，存在有效手术操作："+String.join(",",Base.Intersect(record.ssList,Base.SS_VALID)));
            return "SQY";
        }

        result=SR1.group(record);
        if (result.length()>0){
            return result;
        }

        result=SS1.group(record);
        if (result.length()>0){
            return result;
        }

        result=ST1.group(record);
        if (result.length()>0){
            return result;
        }

        result=SU1.group(record);
        if (result.length()>0){
            return result;
        }

        result=SV1.group(record);
        if (result.length()>0){
            return result;
        }

        result=SZ1.group(record);
        if (result.length()>0){
            return result;
        }

        Base.groupMessages.putMessage(record.Index,"不符合MDCS的ADRG入组条件");
        return "";
    }
}

